<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class InviteLog extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'invite_log';
    
    const SCAN = 0;//浏览
    const REGIST = 1;//注册

    public function student()
    {
        return $this->belongsTo(Student::class, 'student_id', 'id');
    }

    public function sales()
    {
        return $this->belongsTo(Sale::class, 'sales_id', 'id');
    }

    public static function addLog($sales_id, $student_id, $behave)
    {
    	$log = new InviteLog();
    	$log->student_id = $student_id;
    	$log->sales_id = $sales_id;
    	$log->behave = $behave;
    	$log->status = 0;
    	$log->type = 0;
    	$log->save();
    }
}
